﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Admin_ReaderAccount : System.Web.UI.Page
{
    SQL sql = new SQL();
    public static string account;
    protected void Page_Load(object sender, EventArgs e)
    {
        
    }
    protected void i1_TextChanged(object sender, EventArgs e)
    {
         account = sql.EXQSQL("select account from reader_info where readerid='" + i1.Text + "'");
        if (!account.Equals(""))
        {
            i2.Text = account;
            i2.Enabled = false;
            i1.Enabled = false;
        } 
        else
        {
            Response.Write("<script language=javascript>alert('该用户不存在');window.location = 'ReaderAccount.aspx';</script>");
        }
       

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (i2.Enabled==false)
        {
            double yuenow = Convert.ToDouble(account);
            try
            {
                double addMoney = Convert.ToDouble(i3.Text);
                yuenow += addMoney;
                sql.updateAmerce("update Reader_info set Account='" + yuenow + "' where readerid='" + i1.Text + "'");
                Response.Write("<script language=javascript>alert('充值成功');window.location = 'ReaderAccount.aspx';</script>");
            }
            catch (System.Exception ex)
            {
                Response.Write("<script language=javascript>alert('输入的金额有误');window.location = 'ReaderAccount.aspx';</script>");
            }
        } 
        else
        {
        }
    }
    protected void Button1_Click2(object sender, EventArgs e)
    {
        i2.Text = "";
        i1.Text = "";
        i2.Enabled = true;
        i1.Enabled = true;
    }
}